package com.tnovoselec.android.favorites.entity;

import java.util.Properties;

import com.j256.ormlite.field.DataType;
import com.j256.ormlite.field.DatabaseField;
import com.j256.ormlite.table.DatabaseTable;

/**
 * Title: Android Framework - Favorites <br />
 * <br />
 * Copyright: Copyright (c) 2011 <br />
 * <br />
 * NTH Company: NTH d.o.o. <br />
 * <br />
 * 
 * 
 * Enclosures represents multimedia part of news. It can be either image, video,
 * audio, etc. Each of them is represented by its mime type.
 * 
 * @author Tomislav Novoselec
 * @version 1.0.0
 * @since 1.0.0
 */
@DatabaseTable(tableName = "enclosures")
public class EnclosureFavoritesDto extends FavoritesDto {

    public static String keyDescription = "description";
    public static String keyThumbnail = "thumbnail";
    public static String keyThumbUrl = "thumburl";
    public static String keyTitle = "title";

    @DatabaseField(id = true, canBeNull = false, dataType = DataType.INTEGER)
    private Integer id;

    @DatabaseField(canBeNull = true, dataType = DataType.STRING)
    private String url;

    @DatabaseField(canBeNull = true, dataType = DataType.STRING)
    private String mimeType;

    @DatabaseField(canBeNull = true, dataType = DataType.LONG)
    private Long length;

    @DatabaseField(canBeNull = true, dataType = DataType.SERIALIZABLE)
    private Properties properties;

    @DatabaseField(canBeNull = false, dataType = DataType.STRING)
    private String parentChannelId;

    @DatabaseField(canBeNull = true, dataType = DataType.STRING)
    private String relatedArticleGuid;

    public EnclosureFavoritesDto() {
	super();
	properties = new Properties();
    }

    public int getId() {
	return id;
    }

    public void setId(Integer id) {
	this.id = id;
    }

    public String getUrl() {
	return url;
    }

    public void setUrl(String url) {
	this.url = url;
    }

    public String getMimeType() {
	return mimeType;
    }

    public void setMimeType(String mimeType) {
	this.mimeType = mimeType;
    }

    public Long getLength() {
	return length;
    }

    public void setLength(Long length) {
	this.length = length;
    }

    public Properties getProperties() {
	return properties;
    }

    public void setProperties(Properties properties) {
	this.properties = properties;
    }

    public void setProperty(String key, String value) {
	this.properties.setProperty(key, value);
    }

    public String getProperty(String key) {
	return properties.getProperty(key);
    }

    public String getParentChannelId() {
	return parentChannelId;
    }

    public void setParentChannelId(String parentChannelId) {
	this.parentChannelId = parentChannelId;
    }

    public String getRelatedArticleGuid() {
	return relatedArticleGuid;
    }

    public void setRelatedArticleGuid(String relatedArticleGuid) {
	this.relatedArticleGuid = relatedArticleGuid;
    }

    /**
     * String which is used when a table associated with this object type is
     * created
     * 
     * @return String to be executed to create a table
     */
    public static String getCreateQuery() {
	return "CREATE TABLE enclosures (" + "id INTEGER PRIMARY KEY AUTOINCREMENT, " + "url TEXT, " + "mimeType TEXT, " + "relatedArticleGuid TEXT, " + "length LONG, " + "properties BLOB, "
		+ "parentChannelId INTEGER);";
    }

    @Override
    public boolean isValid() {
	// TODO Auto-generated method stub
	return false;
    }

}
